package com.weactivity.controller;

import com.weactivity.dto.AdduserDTO;
import com.weactivity.dto.DeleteDTO;
import com.weactivity.dto.ManageUserDTO;
import com.weactivity.dto.Result;
import com.weactivity.service.ManageUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/manage")
public class ManageUserController {

    @Autowired
    ManageUserService manageUserService;

    /**
     * 更改身份
     *
     * @param manageUserDTO
     * @return
     */
    @PostMapping("/change")
    public Result changeIdentity (@RequestBody ManageUserDTO manageUserDTO){
        manageUserService.changeIdentityByAid(manageUserDTO);
        return Result.ok();
    }

    /**
     * 添加用户
     *
     * @param adduserDTO
     * @return
     */
    @PutMapping("/add")
    public Result add (@RequestBody AdduserDTO adduserDTO){
        manageUserService.add(adduserDTO);
        return Result.ok();
    }
    /**
     * 删除用户
     *
     * @param deleteDTO
     * @return
     */
    @DeleteMapping("/delete")
    public Result delete(@RequestBody DeleteDTO deleteDTO){
        manageUserService.deleteByUid(deleteDTO);
        return Result.ok();
    }
}
